@isTest
private class AvgAccountContactCompleteBatchTest {
    static testMethod void testMethod1() {
        // Id ldcProfile = [Select Id From Profile Where Name ='系统管理员' or Name='System Administrator'].Id;
        Id ldcProfile = [Select Id From Profile Where Name ='销售部分销销售员' ].Id;

    	 User u1 = new User( Alias = 'samLdc1', 
                         Email = 'ldc@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户1', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile, 
                         Country = 'United States',
                         IsActive = true,
                         SubCompany__c='四川省迈克实业有限公司',
                         CompanyName = 'Y-MKSY',
                         FederationIdentifier = '3451',
                         ManagerId = UserInfo.getUserId(),
                         UserDepartment__c='客户服务中心(工程部)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123451',
                         Username = 'Matldc1@test.com.maike',
                         ResponseCode__c = 'TTTT' );
    	 insert u1;

        Account a = new Account();
        a.Name='测试';
        a.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('Dealer', 'Account');
        a.OwnerId = u1.Id ; 
        insert a;
        Contact c = new Contact();
        c.AccountId = a.Id ; 
        c.LastName = 'xxx';
        c.Post__c = '总经理';
        insert c ;

        Account a1 = new Account();
        a1.Name='测试sssss';
        a1.OwnerId = u1.Id ; 
        a1.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('TerminalCustomer', 'Account');
        insert a1;

         Contact c1 = new Contact();
        c1.AccountId = a1.Id ; 
        c1.LastName = 'xxx';
        c1.Departments__c = '医院办公室';
        c1.Post__c = '院长';
        c1.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('TerminalCustomer', 'Contact'); 
        insert c1 ;


        AvgAccountContactCompleteBatch ba = new AvgAccountContactCompleteBatch();

        Database.executeBatch(ba, 100);

         AvgAccountContactsCompleteSchedule sc = new AvgAccountContactsCompleteSchedule();
        String fmt = '0 10 0 1-31 1-12 ? 2017-2098';//每天执行一次
        System.schedule('每天刷新客户联系人信息完整度 计划任务；'+Datetime.now().format('yyyyMMddHHmmss'), fmt, sc);

    }
}